﻿using System.Text;
using LitJson;

namespace ExcelConverter
{
    public class CodeWriter
    {
        private readonly StringBuilder m_builder;
        private readonly JsonWriter m_writer;
        public CodeWriter()
        {
            m_builder = new StringBuilder(128);
            m_writer = new JsonWriter(m_builder);
            m_writer.PrettyPrint = true;
        }

        public CodeWriter WriteExcelStart()
        {
            m_writer.WriteArrayStart();
            return this;
        }
        public CodeWriter WriteExcelEnd()
        {
            m_writer.WriteArrayEnd();
            return this;
        }
        public CodeWriter WriteArrayStart()
        {
            m_writer.WriteArrayStart();
            return this;
        }
        public CodeWriter WriteArrayEnd()
        {
            m_writer.WriteArrayEnd();
            return this;
        }
        public CodeWriter WriteObjectStart()
        {
            m_writer.WriteObjectStart();
            return this;
        }
        public CodeWriter WriteObjectEnd()
        {
            m_writer.WriteObjectEnd();
            return this;
        }
        
        public CodeWriter WritePropertyName(string name)
        {
            m_writer.WritePropertyName(name);
            return this;
        }
        public CodeWriter Write(int value)
        {
            m_writer.Write(value);
            return this;
        }
        public CodeWriter Write(ulong value)
        {
            m_writer.Write(value);
            return this;
        }
        public CodeWriter Write(double value)
        {
            m_writer.Write(value);
            return this;
        }
        public CodeWriter Write(string value)
        {
            m_writer.Write(value);
            return this;
        }
        public CodeWriter Write(bool value)
        {
            m_writer.Write(value ? 1 : 0);
            return this;
        }

        public void InsertId(int id)
        {
            
        }
        public void InsertId(string id)
        {
            
        }

        public override string ToString()
        {
            return m_builder.ToString();
        }
    }
}